package PAT.乙.模拟;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 挖掘机技术哪家强
 *
 * @author yang
 * @date 2021/12/13
 */
public class 挖掘机技术哪家强 {

/*    static int N = 100010;
    static int n;
    static Map<Integer, Integer> map = new HashMap<>();
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(br.readLine());

        for (int i = 0; i < n; i++) {
            String[] s = br.readLine().split(" ");
            int key = Integer.parseInt(s[0]);
            int value = Integer.parseInt(s[1]);
            if (map.containsKey(key)) {
                map.put(key,map.get(key) + value);
            } else {
                map.put(key,value);
            }

        }
        int id = 0;
        int scope = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            Integer value = entry.getValue();
            if (scope < value) {
                scope = value;
                id = entry.getKey();
            }
        }
        System.out.println(id + " " + scope);

    }*/


    // 写法二数组模拟哈希表

    static int N = 100010;
    static int[] school = new int[N];
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        for (int i = 1; i <= n; i++) {
            String[] s = br.readLine().split(" ");
            int id = Integer.parseInt(s[0]);
            int score = Integer.parseInt(s[1]);
            school[id] += score;

        }
        int k = 0, max = -1;
        for (int i = 1; i <= n; i++) {
            if (school[i] > max) {
                max = school[i];
                k = i;
            }
        }
        System.out.println(k + " " + max);
    }

}
